package top.serms.leetcode;

import java.util.ArrayList;
import java.util.List;

public class LeetCode27 {
    public static void main(String[] args) {
        int[] nums = {0,1,2,2,3,0,4,2};
        removeElementSpeedIndicator(nums,2);
    }

    public static int removeElementSpeedIndicator(int[] nums, int val) {
        List<Integer> list = new ArrayList<>();
        for (int num : nums) {
            if (num != val) {
                list.add(num);
            }
        }
        int[] result = new int[list.size()];
        for (int i = 0; i < list.size(); i++) {
            result[i] = list.get(i);
            System.out.print(result[i] + " ");
        }
        nums = result;
        for (int num : nums) {
            System.out.println(num);
        }
        return result.length;
    }
}
